package ru.st.selenium.applogic2;

import java.util.List;

import ru.st.selenium.applogic.FilmHelper;
import ru.st.selenium.model.Film;

public class FilmHelper2 extends DriverBasedHelper implements FilmHelper {

  public FilmHelper2(ApplicationManager2 manager) {
    super(manager.getWebDriver());
  }

  @Override
  public void create(Film film) {
    pages.internalPage
      .clickfilmManagementLink()
      .setFilmNameField(film.getTitle())
      .setYearField(film.getYear())
      .clickSubmitButton();
  }

  @Override
  public void delete(Film film) {
    pages.internalPage
    .clickanyFilmLink()
    .clickRemoveButton();
  }

  @Override
  public List<Film> search(String title) {
    pages.filmListPage
    .setSearchNameFilm(title);    
    return null;
  }

  @Override
  public boolean isFindFilmFail() {
	return pages.filmListPage
			.getSearchFirstNameFilm().equals("No movies where found.");
  }

  @Override
  public boolean isFindFilmOK(String film) {
	return getAnyNameFilm().getTitle().equals(film);
  }
  
  @Override
  public Film getAnyNameFilm(){
	  return  new Film()
	  .setTitle(pages.filmListPage.getSearchAnyNameFilm());
  }

}
